
*** Paper on political self-efficacy and accumulated stratification ***
* do file by Jaap van Slageren, Hester Mennes en Michelle Rosmalen, 28th of August 2024

***********************************************************************************************

* Select the right dataset
clear all
use "C:\Users\4023609\OneDrive - UvA\ADKS\Dataverzameling\Data en documentatie\Data final/data final ENG incl PRO_long.dta", clear
set more off
cd "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses"

* I delete practical education from the analyses;
* for this track, different phrasings were used in the questionnaire.
* Therefore, comparability is not entirely ensured. 
* important to note; 41 of the students who had a regular survey in year 1
* switched to the practical survey in a later year
drop if idtest==2

* DATA SELECTION
tab idtest if wave==1 // so 2070 respondents in the regular study in year 1
tab idtest if wave==2 // 2022 respondents in the regular study in year 2
tab idtest if wave==3 // 1044 respondents in the regular study in year 3
tab idtest if wave==4 // 1445 respondents in the regular study in year 4

* Drop wave 5 and 6 because of unbalance across tracks
drop if wave>4
* check how many classes in year 1:
codebook idclass if wave==1


* DATA RECODING

* Dependent variable: political efficacy, both internal and external

	*** Internal efficacy

		* 'I do not know' also coded as missing here
		codebook  effin1
		codebook  effin2
		codebook  effin3
		codebook  effin4
		recode effin1 effin2 effin3 effin4 (997 998 =.) 
		codebook  effin1
		codebook  effin2
		codebook  effin3
		codebook  effin4
		
		* create one scale:
		gen poleff = (effin1+effin2+effin3+effin4)/4
		egen poleffin = rowmean(effin1 effin2 effin3 effin4)
		egen help1 = rowmiss(effin1 effin2 effin3 effin4)
		replace poleffin=. if help1>2
		drop help1
		* then check the scale:
		factor effin1 effin2 effin3 effin4 // strong support for 1 scale
		// factor loadings range from .68 to .84
		alpha effin1 effin2 effin3 effin4 if wave==1, i //0.85 no removal is better
		alpha effin1 effin2 effin3 effin4 if wave==2, i // 0.86 only slightly better without effin 4. 
		alpha effin1 effin2 effin3 effin4 if wave==3, i //0.87 no removal is better
		alpha effin1 effin2 effin3 effin4 if wave==4, i // 0.89 only slightly better without effin 4. 


	*** External efficacy (no wave 2 available)
	* wave 1 (has already been reversed recoded)
		codebook  effex1rec
		codebook  effex2rec
		recode effex1rec effex2rec (997 998 .a .b =.) 
		codebook  effex1rec
		codebook  effex2rec
		
		* then check the combination:
		alpha effex1rec effex2rec if wave==1
		alpha effex1rec effex2rec if wave==3
		alpha effex1rec effex2rec if wave==4
		* create one scale:
		gen poleffx = (effex1rec+effex2rec)/2
	
	

sum poleffx

	
	

* Sociodemographic characteristics
		
	* Gender 
			* The information respondents gave in wave 1 is used. 
			* Missings will be filled with later waves (gennum)
			recode gender (998 =.), gen(gndr)
			
			tab gndr
			codebook gndr // still 42 missings
		
			
	* Socioeconomic factors
			* or educational attainment of parents
			fre edum 
			fre eduf 
		
			*mother
			recode edum (0 = 87.13) (1 = 77.93) (2 = 52.70) (3 = 71.92) (4 = 62.30) (5 = 45.27) (6 = 22.98) (7 = 22.98) ( 997 998 = .), gen(edum_isled)
			recode edum (3 4 5 6 7 = 0) (2 = 1) (0 1 = 2) (997 998 = .)
			lab def eduparents 0 "nontertiary" 1 "vocational tertiary" 2 "academic tertiary"
			lab val edum eduparents 
			fre edum
			
			* father
			recode eduf (0 = 87.13) (1 = 77.93) (2 = 52.70) (3 = 71.92) (4 = 62.30) (5 = 45.27) (6 = 22.98) (7 = 22.98) (997 998 = .), gen(eduf_isled)
			recode eduf (3 4 5 6 7 = 0) (2 = 1) (0 1 = 2) (997 998 = .)
			lab val eduf eduparents 
			fre eduf			
			
			tab  edum eduf, m
			g edupar=.
			recode edupar (.=0)if edum==0 & eduf==0
			recode edupar (.=0)if edum==0 & eduf==.
			recode edupar (.=0)if edum==. & eduf==0
			
			recode edupar (.=1)if edum<=1 & eduf==1
			recode edupar (.=1)if edum==1 & eduf<=1
			recode edupar (.=1)if edum==1 & eduf==.
			recode edupar (.=1)if edum==. & eduf==1
			
			recode edupar (.=2)if edum<=2 & eduf==2
			recode edupar (.=2)if edum==2 & eduf<=2
			recode edupar (.=2)if edum==2 & eduf==.
			recode edupar (.=2)if edum==. & eduf==2
			lab val edupar eduparents 			
			
			gen edupar_isled = edum_isled
			replace edupar_isled = eduf_isled if edum_isled==.
			replace edupar_isled = eduf_isled if (eduf_isled>edum_isled & eduf_isled!=.)
			egen edupar_isled_mean = rowmean(edum_isled eduf_isled)
			bys idstudent: egen edupar_isled1=mean(edupar_isled)
			drop edupar_isled
			rename edupar_isled1 edupar_isled
			egen zedupar_isled= std(edupar_isled)

			
	* Track for each year
			* respondents can switch track each year,
			* to a more thereotical or practical oriented track for example. 
			* in addition, in later years tracks sometimes split
			* hence important to distinguish between years
			
			codebook track 

			
			recode track (1/2=1)(3 4=2)(5=3)(6=4)(7=5)(8/10=6) (11 997 998=.), gen(opl)
		
	
			
			label define opl 1 "vmbo" 2 "vmbo/havo" 3 "brede brugklas" 4 "havo" 5 "havo/vwo" 6 "vwo", replace 
			label values opl opl	
			
			* Recode in a more simplified way
			
			recode opl (1 = 0 ) (4 5 6 = 1) 
	
			label define trackl 0 "vocational" 1 "academic" 2 "vocationalgeneral" 3 "mixed", replace 
			label values opl trackl
			codebook opl
			
		* because category 2 and 3 only exist in the first two waves, I further simplify
			recode opl (2 3 = .)
* Migration background
			recode migra (0=0) (1 2 = 1), gen(migration)

	
* Political Interest
			*recode missings
			recode intpol (997 998 = .)
			
			keep opl books age poleffin poleffx effin1 effin2 effin3 effin4 effex1 effex2 parpol fripol teapol intpol edupar_isled zedupar_isled opl gndr books age migration idstudent idclass idschool wave
			
// change the data from long to wide
reshape wide opl books age poleffin poleffx effin1 effin2 effin3 effin4 effex1 effex2 parpol fripol teapol intpol idclass idschool, i(idstudent) j(wave)


	* Number of books at home (cultural capital)
			codebook books*
		
			recode books1 (997 998 =.)
			recode books2 (997 998 =.)
			recode books3 (997 998 =.)
			recode books4 (997 998 =.)
			
			gen books= books1
			replace books=books2 if books==.
			replace books=books3 if books==.
			replace books=books4 if books==.
			
			lab def booksl 0 "zero to 10 books" 1 "11 to 50 books" 2 "51 to 100 books" 3 "101 to 200 books" 4 "201 to 500 books" 5 "more than 500 books"
			label values books booksl
			egen zbooks = std(books)
			
	* and next I create a time invariant track variable
			* I take the most recent track track position as the base
			* and impute track info from previous years in case of missings
			g academic = opl4
			replace academic=opl3 if academic==.
			replace academic=opl2 if academic==.
			replace academic=opl1 if academic==.
			
			tab academic opl4
			tab academic opl3
			tab academic opl2
			tab academic opl1
			
			lab def track 0 "Vocational" 1 "Academic"
			lab val academic track	
			
			gen age=age1
			replace age=(age2-1) if age==.
			replace age=(age3-2) if age==.
			replace age=(age4-3) if age==.
			egen zage = std(age)
	
	
* Socialization variables

	* discussion with parents about politics in the Netherlands 
			codebook parpol1
			codebook parpol2
			codebook parpol4
	
			recode parpol1 parpol2 parpol4 (997 998= .) 
			egen oudpol_mean= rowmean(parpol1 parpol2 parpol4)	
			
	* REWB calculation
			gen op_mean_w1 = parpol1 - oudpol_mean	
			gen op_mean_w2 = parpol2 - oudpol_mean	
			gen op_mean_w4 = parpol4 - oudpol_mean	
			
	* discussion with friends about politics in the Netherlands 
			codebook fripol1
			codebook fripol2
			codebook fripol4
	
			recode fripol1 fripol2 fripol4 (997 998 = .)
			egen vripol_mean= rowmean(fripol1 fripol2 fripol4)	
	
	* REWB calculation
			gen vp_mean_w1 = fripol1 - vripol_mean	
			gen vp_mean_w2 = fripol2 - vripol_mean	
			gen vp_mean_w4 = fripol4 - vripol_mean	
			
	* discussion with teachers about politics in the Netherlands 
			codebook teapol1
			codebook teapol2
			codebook teapol4
	
			recode teapol1 teapol2 teapol4 (997 998= .)
			egen lerpol_mean= rowmean(teapol1 teapol2 teapol4)
			
	* REWB calculation
			gen lp_mean_w1 = teapol1 - lerpol_mean	
			gen lp_mean_w2 = teapol2 - lerpol_mean	
			gen lp_mean_w4 = teapol4 - lerpol_mean	
			
	* overall discussion with teachers
			egen discuss_mean_1= rowmean(parpol1 fripol1 teapol1)
			egen discuss_mean_2= rowmean(parpol2 fripol2 teapol2)
			egen discuss_mean_4= rowmean(parpol4 fripol4 teapol4)
	
			egen discuss_mean_mean= rowmean(discuss_mean_1 discuss_mean_2 discuss_mean_4)
			
	* REWB calculation
			gen disc_mean_w1 = discuss_mean_1 - discuss_mean_mean	
			gen disc_mean_w2 = discuss_mean_2 - discuss_mean_mean	
			gen disc_mean_w4 = discuss_mean_4 - discuss_mean_mean	
			
	* proportion discussion by actor
		gen oud_disc_prop_1 = parpol1/(parpol1+fripol1+teapol1)
		gen vri_disc_prop_1 = fripol1/(parpol1+fripol1+teapol1)
		gen ler_disc_prop_1 = teapol1/(parpol1+fripol1+teapol1)
		gen oud_disc_prop_2 = parpol2/(parpol2+fripol2+teapol2)
		gen vri_disc_prop_2 = fripol2/(parpol2+fripol2+teapol2)
		gen ler_disc_prop_2 = teapol2/(parpol2+fripol2+teapol2)
		gen oud_disc_prop_4 = parpol4/(parpol4+fripol4+teapol4)
		gen vri_disc_prop_4 = fripol4/(parpol4+fripol4+teapol4)
		gen ler_disc_prop_4 = teapol4/(parpol4+fripol4+teapol4)
		
	* REWB calculation
		egen oud_disc_prop_mean = rowmean(oud_disc_prop_1 oud_disc_prop_2 oud_disc_prop_4) 	
		gen disc_oud_prop_w1 = oud_disc_prop_1 - oud_disc_prop_mean
		gen disc_oud_prop_w2 = oud_disc_prop_2 - oud_disc_prop_mean	
		gen disc_oud_prop_w4 = oud_disc_prop_4 - oud_disc_prop_mean	
		
		egen vri_disc_prop_mean = rowmean(vri_disc_prop_1 vri_disc_prop_2 vri_disc_prop_4) 	
		gen disc_vri_prop_w1 = vri_disc_prop_1 - vri_disc_prop_mean
		gen disc_vri_prop_w2 = vri_disc_prop_2 - vri_disc_prop_mean	
		gen disc_vri_prop_w4 = vri_disc_prop_4 - vri_disc_prop_mean	
		
		egen ler_disc_prop_mean = rowmean(ler_disc_prop_1 ler_disc_prop_2 ler_disc_prop_4) 	
		gen disc_ler_prop_w1 = ler_disc_prop_1 - ler_disc_prop_mean
		gen disc_ler_prop_w2 = ler_disc_prop_2 - ler_disc_prop_mean	
		gen disc_ler_prop_w4 = ler_disc_prop_4 - ler_disc_prop_mean	
	
			lab def genderl 0 "Boys" 1 "Girls"
			lab val gndr genderl 
		
	save "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", replace
	
* IVs listed:
** gndr (1 = girl)
** edupar (highest parental educational attainment ISLED)
** books (5 categories)
** academic (track)
** migration (1 = yes)	
** intpol (5 categories) (political interest)		
** oudpol, vripol, lerpol (frequency discussion with soc. actors)	


***************		 PANEL ATTRITION AND DESCRIPTIVES		***************
{
* INTERNAL POLITICAL EFFICACY
use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear 

* I take wave 1 as the basis
keep if poleffin1!=.

	
* Attrition check
	tab poleffin1 poleffin2 //1374 cases of the 2027 cases remain
	tab poleffin1 poleffin3 //718 cases of the 2027 cases remain
	tab poleffin1 poleffin4 //632 cases of the 2027 cases remain
	
	g attrition12=.
	recode attrition12 (.=1)  if poleffin2==.
	recode attrition12 (.=0)  if poleffin2!=.
	fre attrition12
	
	g attrition13=.
	recode attrition13 (.=1)  if poleffin3==.
	recode attrition13 (.=0)  if poleffin3!=. 
	fre attrition13

	g attrition14=.
	recode attrition14 (.=1)  if poleffin4==.
	recode attrition14 (.=0)  if poleffin4!=. 
	fre attrition14
	
	* test statistical difference between missings and nonmissings
	*for wave 1 compared to wave 2
	mean poleffin1, over(attrition12)
	lincom _b[c.poleffin1@0bn.attrition12] - _b[c.poleffin1@1.attrition12] 
	*for wave 1 compared to wave 3
	mean poleffin1, over(attrition13)
	lincom _b[c.poleffin1@0bn.attrition13] - _b[c.poleffin1@1.attrition13]
	*for wave 1 compared to wave 4
	mean poleffin1, over(attrition14)
	lincom _b[c.poleffin1@0bn.attrition14] - _b[c.poleffin1@1.attrition14]
	
	* AGE
	*for wave 1 compared to wave 2
	mean age, over(attrition12)
	lincom _b[c.age@0bn.attrition12] - _b[c.age@1.attrition12]
	*for wave 1 compared to wave 3
	mean age, over(attrition13)
	lincom _b[c.age@0bn.attrition13] - _b[c.age@1.attrition13]
	*for wave 1 compared to wave 4
	mean age, over(attrition14)
	lincom _b[c.age@0bn.attrition14] - _b[c.age@1.attrition14]
	
	* GENDER
	*for wave 1 compared to wave 2
	mean gndr, over(attrition12)
	lincom _b[c.gndr@0bn.attrition12] - _b[c.gndr@1.attrition12] 
	*for wave 1 compared to wave 3
	mean gndr, over(attrition13)
	lincom _b[c.gndr@0bn.attrition13] - _b[c.gndr@1.attrition13]  
	*for wave 1 compared to wave 4
	mean gndr, over(attrition14)
	lincom _b[c.gndr@0bn.attrition14] - _b[c.gndr@1.attrition14] 
	
	* TRACK
	*for wave 1 compared to wave 2
	mean academic, over(attrition12)
	lincom _b[c.academic@0bn.attrition12] - _b[c.academic@1.attrition12]
	*for wave 1 compared to wave 3
	mean academic, over(attrition13)
	lincom _b[c.academic@0bn.attrition13] - _b[c.academic@1.attrition13]
	*for wave 1 compared to wave 4
	mean academic, over(attrition14)
	lincom _b[c.academic@0bn.attrition14] - _b[c.academic@1.attrition14]
	
	* PEA
	*for wave 1 compared to wave 2
	mean zedupar_isled, over(attrition12)
	lincom _b[c.zedupar_isled@0bn.attrition12] - _b[c.zedupar_isled@1.attrition12] // nonsig
	*for wave 1 compared to wave 3
	mean zedupar_isled, over(attrition13)
	lincom _b[c.zedupar_isled@0bn.attrition13] - _b[c.zedupar_isled@1.attrition13] // significant 
	*for wave 1 compared to wave 4
	mean zedupar_isled, over(attrition14)
	lincom _b[c.zedupar_isled@0bn.attrition14] - _b[c.zedupar_isled@1.attrition14] // nonsig 
	
	* Cultural Capital
	*for wave 1 compared to wave 2
	mean books, over(attrition12)
	lincom _b[c.books@0bn.attrition12] - _b[c.books@1.attrition12] 
	*for wave 1 compared to wave 3
	mean books, over(attrition13)
	lincom _b[c.books@0bn.attrition13] - _b[c.books@1.attrition13]
	*for wave 1 compared to wave 4
	mean books, over(attrition14)
	lincom _b[c.books@0bn.attrition14] - _b[c.books@1.attrition14]
	
		
	* Migration
	*for wave 1 compared to wave 2
	mean migration, over(attrition12)
	lincom _b[c.migration@0bn.attrition12] - _b[c.migration@1.attrition12] 
	*for wave 1 compared to wave 3
	mean migration, over(attrition13)
	lincom _b[c.migration@0bn.attrition13] - _b[c.migration@1.attrition13] 
	*for wave 1 compared to wave 4
	mean migration, over(attrition14)
	lincom _b[c.migration@0bn.attrition14] - _b[c.migration@1.attrition14] 
	
	* EXTERNAL POLITICAL EFFICACY
use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear 
* I take wave 1 as the basis
keep if poleffx1!=.

	
* Attrition check
	tab poleffx1 poleffx3 //600 cases remain
	tab poleffx1 poleffx4 //504 cases remain

	
	g xattrition13=.
	recode xattrition13 (.=1)  if poleffx3==.
	recode xattrition13 (.=0)  if poleffx3!=. 
	fre xattrition13

	g xattrition14=.
	recode xattrition14 (.=1)  if poleffx4==.
	recode xattrition14 (.=0)  if poleffx4!=. 
	fre xattrition14
	
	* test statistical difference between missings and nonmissings
	*for wave 1 compared to wave 3
	mean poleffx1, over(xattrition13)
	lincom _b[c.poleffx1@0bn.xattrition13] - _b[c.poleffx1@1.xattrition13]
	*for wave 1 compared to wave 4
	mean poleffx1, over(xattrition14)
	lincom _b[c.poleffx1@0bn.xattrition14] - _b[c.poleffx1@1.xattrition14] 
	
	* Political interest
use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear 

* I take wave 1 as the basis
keep if intpol1!=.

	
* Attrition check
	tab intpol1 intpol2 //1412 cases of the 2063 cases remain
	tab intpol1 intpol3 //752 cases of the 2063 cases remain
	tab intpol1 intpol4 //666 cases of the 2063 cases remain
	
	g attrition12=.
	recode attrition12 (.=1)  if intpol2==.
	recode attrition12 (.=0)  if intpol2!=.
	fre attrition12
	
	g attrition13=.
	recode attrition13 (.=1)  if intpol3==.
	recode attrition13 (.=0)  if intpol3!=. 
	fre attrition13

	g attrition14=.
	recode attrition14 (.=1)  if intpol4==.
	recode attrition14 (.=0)  if intpol4!=. 
	fre attrition14
	
	* test statistical difference between missings and nonmissings
	*for wave 1 compared to wave 2
	mean intpol1, over(attrition12)
	lincom _b[c.intpol1@0bn.attrition12] - _b[c.intpol1@1.attrition12] 
	*for wave 1 compared to wave 3
	mean intpol1, over(attrition13)
	lincom _b[c.intpol1@0bn.attrition13] - _b[c.intpol1@1.attrition13]
	*for wave 1 compared to wave 4
	mean intpol1, over(attrition14)
	lincom _b[c.intpol1@0bn.attrition14] - _b[c.intpol1@1.attrition14] 
	
	* Political discussions parents
use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear 

* I take wave 1 as the basis
keep if parpol1!=.

	
* Attrition check
	tab parpol1 parpol2 //1376 cases of the 2026 cases remain
	tab parpol1 parpol4 //645 cases of the 2026 cases remain
	
	g attrition12=.
	recode attrition12 (.=1)  if parpol2==.
	recode attrition12 (.=0)  if parpol2!=.
	fre attrition12

	g attrition14=.
	recode attrition14 (.=1)  if parpol4==.
	recode attrition14 (.=0)  if parpol4!=. 
	fre attrition14
	
	* test statistical difference between missings and nonmissings
	*for wave 1 compared to wave 2
	mean parpol1, over(attrition12)
	lincom _b[c.parpol1@0bn.attrition12] - _b[c.parpol1@1.attrition12]
	*for wave 1 compared to wave 4
	mean parpol1, over(attrition14)
	lincom _b[c.parpol1@0bn.attrition14] - _b[c.parpol1@1.attrition14] 
	
	
	* Political discussions peers
use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear 

* I take wave 1 as the basis
keep if fripol1!=.

	
* Attrition check
	tab fripol1 fripol2 //1391 cases of the 2048 cases remain
	tab fripol1 fripol4 //653 cases of the 2048 cases remain
	
	g attrition12=.
	recode attrition12 (.=1)  if fripol2==.
	recode attrition12 (.=0)  if fripol2!=.
	fre attrition12

	g attrition14=.
	recode attrition14 (.=1)  if fripol4==.
	recode attrition14 (.=0)  if fripol4!=. 
	fre attrition14
	
	* test statistical difference between missings and nonmissings
	*for wave 1 compared to wave 2
	mean fripol1, over(attrition12)
	lincom _b[c.fripol1@0bn.attrition12] - _b[c.fripol1@1.attrition12] // nonsig
	*for wave 1 compared to wave 4
	mean fripol1, over(attrition14)
	lincom _b[c.fripol1@0bn.attrition14] - _b[c.fripol1@1.attrition14] // nonsig 	
	
		* Political discussions teachers
use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear 

* I take wave 1 as the basis
keep if teapol1!=.

	
* Attrition check
	tab teapol1 teapol2 //1330 cases of the 1969 cases remain
	tab teapol1 teapol4 //625 cases of the 1969 cases remain
	
	g attrition12=.
	recode attrition12 (.=1)  if teapol2==.
	recode attrition12 (.=0)  if teapol2!=.
	fre attrition12

	g attrition14=.
	recode attrition14 (.=1)  if teapol4==.
	recode attrition14 (.=0)  if teapol4!=. 
	fre attrition14
	
	* test statistical difference between missings and nonmissings
	*for wave 1 compared to wave 2
	mean teapol1, over(attrition12)
	lincom _b[c.teapol1@0bn.attrition12] - _b[c.teapol1@1.attrition12] // significant
	*for wave 1 compared to wave 4
	mean teapol1, over(attrition14)
	lincom _b[c.teapol1@0bn.attrition14] - _b[c.teapol1@1.attrition14] // significant 	
	
	
	}
	* Descriptives table
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear 

	*time constant
	drop if zedupar_isled==. | academic==. | age==. | migration==. | gndr==. | books==. 
	drop if poleffin1==. & poleffin2==. & poleffin3==. & poleffin4==.
	drop if poleffin1==. & poleffin2==. & poleffin3==. & poleffin4==. & poleffx1==. & poleffx3==. & poleffx4==.
	sum edupar_isled academic gndr books age migration 
	
	*time varying
	reshape long poleffin poleffx parpol teapol fripol discuss_mean_ intpol, i(idstudent) j(wave)	
	drop if poleffin==. & poleffx==.
	drop if intpol==.
	sum poleffin poleffx discuss_mean_ parpol teapol fripol intpol i.wave

	

***************		 ANALYSIS INTERNAL POLITICAL EFFICACY		***************

	* for footnote: R2 of PE wave 4 when checking for PE wave 1

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear 
	corr poleffin4 poleffin3
	corr poleffin4 poleffin2
	corr poleffin4 poleffin1
	corr poleffin3 poleffin2
	corr poleffin3 poleffin1
	corr poleffin2 poleffin1
	
	
	corr poleffx4 poleffx3
	corr poleffx4 poleffx1
	corr poleffx3 poleffx1

	reshape long poleffin poleffx idclass, i(idstudent) j(wave)	
	mixed poleffin ||idstudent:
	estat icc
	mixed poleffx ||idstudent:
	estat icc
	
	***************					MAIN ANALYSES				***************
	***************		 ANALYSIS INTERNAL POLITICAL EFFICACY	***************

	* Part 1: Inequalities in Year 1: 
	{
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear
keep if poleffin1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)
	
	// Baseline multilevel model: Significant differences in Gender, Track, Parental educational attainment, Cultural capital and Migration background.
	regress poleffin age gndr academic zedupar_isled books migration intpol if wave==1
	est store IPE_1_1
	
estout IPE_1_1 using "Part 1 Internal Political Efficacy new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	}
	
	*** Figure 1: development of political efficacy over time
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
	keep if poleffin1!=.
	gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if poleffin==. | age==. | gndr==. | academic==. | zedupar_isled==. | books==. | migration==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	xtmixed poleffin i.wave age gndr academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	margins wave 
	marginsplot, title("Panel A: Internal Political Efficacy") ///
	ytitle("Average IPE") legend(size(vsmall)) xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") saving("Figure 1 IPE new", replace)

	
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
	keep if poleffx1!=.
gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if poleffx==. | age==. | gndr==. | academic==. | zedupar_isled==. | books==. | migration==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	xtmixed poleffx i.wave age gndr academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	margins wave 
	marginsplot, title("Panel B: External Political Efficacy") ///
	ytitle("Average EPE") legend(size(vsmall)) xtitle("Grade") xlab(1 "7" 3 "9" 4 "10") saving("Figure 1 EPE new", replace)

graph combine "Figure 1 IPE new" "Figure 1 EPE new" , title("") saving("Figure 1 new.gph", replace)
	
	
	
	* Part 2: Development of of these inequalities over time, using Growth Curve Modelling: 
	{
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffin1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lerpol_ lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if poleffin==. | age==. | gndr==. | academic==. | zedupar_isled==. | books==. | migration==. 
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// The growth curve model: 
	xtmixed poleffin wave age gndr academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_1
	mltrsq 
	// The growth curve model with interaction on gender: not significant
	xtmixed poleffin c.wave##gndr age academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_2
	mltrsq
	
	margins , at(wave=(1(1)4) gndr=(0 1))
	marginsplot, title("Panel A: Gender") ///
	ytitle("Average IPE") xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") saving("Figure 2 Panel A new", replace) 
	
	// The growth curve model with interaction on track: significant negative
	xtmixed poleffin c.wave##academic gndr age zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_3
	mltrsq
	
	margins , at(wave=(1(1)4) academic=(0 1))
	marginsplot, title("Panel B: Academic Track") ///
	ytitle("Average IPE") xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") saving("Figure 2 Panel B new", replace) 
	
	// The growth curve model with interaction on PEA: significant negative
	xtmixed poleffin c.wave##c.zedupar_isled academic gndr age books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_4
	mltrsq
	margins , at(wave=(1(1)4) zedupar_isled=(-2(2)2))
	marginsplot, title("Panel C: Parental Educational Attainment") ///
	ytitle("Average IPE") xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") legend(order(1 "PEA -2 SD" 2 "PEA Mean"  3 "PEA +2 SD")) saving("Figure 2 Panel C new", replace) 
	
	
	// The growth curve model with interaction on cultural capital: significant negative
	xtmixed poleffin c.wave##c.books zedupar_isled academic gndr age migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_5
	mltrsq
	margins , at(wave=(1(1)4) books=(0(1)5))
	marginsplot, title("Panel D: Cultural Capital") ///
	ytitle("Average IPE") legend(size(vsmall)) xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") saving("Figure 2 Panel D new", replace) 
	
	
	estout IPE_2_1 IPE_2_2 IPE_2_3 IPE_2_4 IPE_2_5 using "Part 2 Internal Political Efficacy new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	
graph combine "Figure 2 Panel A new.gph" "Figure 2 Panel B new.gph" "Figure 2 Panel C new.gph" "Figure 2 Panel D new.gph", title("") saving("Figure 2 new.gph", replace)
	
	
	}


	* Part 3: Random Effect Within-Between model to disentangle the effect op political socialisation.
	{
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffin1!=.
	gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if poleffin==. | age==. | gndr==. | academic==. | zedupar_isled==. | books==. | migration==. | parpol==. | fripol==. | teapol==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// Baseline Multilevel model
	xtmixed poleffin i.wave age gndr academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_1
	mltrsq
	
	// REWB model total socialisation:
	xtmixed poleffin i.wave age gndr academic zedupar_isled books migration intpol discuss_mean_mean disc_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_2
	mltrsq
		
	// REWB model seperate socialisations:
	xtmixed poleffin i.wave age gndr academic zedupar_isled books migration intpol oudpol_mean op_mean_w vripol_mean vp_mean_w lerpol_mean lp_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_3
	mltrsq
	
	estout IPE_3_1 IPE_3_2 IPE_3_3 using "Part 3 Internal Political Efficacy new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	
	}
	
	
***************		 ANALYSIS EXTERNAL POLITICAL EFFICACY		***************



	* Part 1: Inequalities in Year 1: 
	{
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)
	
	// Baseline multilevel model: Significant differences in academic track and Cultural capital.
	regress poleffx age gndr academic zedupar_isled books migration intpol if wave==1 
	est store EPE_1_1
	
estout EPE_1_1 using "Part 1 External Political Efficacy new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	}
	
	* Part 2: Development of of these inequalities over time, using Growth Curve Modelling: 
	{
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)	
	drop if poleffx==. | age==. | gndr==. | academic==. | zedupar_isled==. | books==. | migration==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// The growth curve model: 
	xtmixed poleffx wave age gndr academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_1
	mltrsq 
	// The growth curve model with interaction on gender: not significant
	xtmixed poleffx c.wave##gndr age academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_2
	mltrsq
	margins , at(wave=(1(1)4) gndr=(0 1))
	marginsplot, title("Panel A: Gender") ///
	ytitle("Average EPE") legend(size(vsmall)) xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") saving("Figure 3 Panel A new", replace) 
	
	// The growth curve model with interaction on track: significant negative
	xtmixed poleffx c.wave##academic gndr age zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_3
	mltrsq
	margins , at(wave=(1(1)4) academic=(0 1))
	marginsplot, title("Panel B: Academic Track") ///
	ytitle("Average EPE") legend(size(vsmall)) xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") saving("Figure 3 Panel B new", replace) 
	
	// The growth curve model with interaction on PEA: not signficant
	xtmixed poleffx c.wave##c.zedupar_isled academic gndr age books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_4
	mltrsq
	margins , at(wave=(1(1)4) zedupar_isled=(-2(2)2))
	marginsplot, title("Panel C: Parental Educational Attainment") ///
	ytitle("Average EPE") xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") legend(order(1 "PEA -2 SD" 2 "PEA Mean"  3 "PEA +2 SD")) saving("Figure 3 Panel C new", replace) 
	
	// The growth curve model with interaction on cultural capital: significant negative
	xtmixed poleffx c.wave##c.books academic gndr age zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_5
	mltrsq
	margins , at(wave=(1(1)4) books=(0(1)5))
	marginsplot, title("Panel D: Cultural Capital") ///
	ytitle("Average EPE") legend(size(vsmall)) xtitle("Grade") xlab(1 "7" 2 "8" 3 "9" 4 "10") saving("Figure 3 Panel D new", replace) 
	
	
	
	estout EPE_2_1 EPE_2_2 EPE_2_3 EPE_2_4 EPE_2_5 using "Part 2 External Political Efficacy new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	
	
graph combine "Figure 3 Panel A.gph" "Figure 3 Panel B.gph" "Figure 3 Panel C.gph" "Figure 3 Panel D.gph", title("") saving("Figure 3 new.gph", replace)
	
	}


	* Part 3: Random Effect Within-Between model to disentangle the effect op political socialisation.
	{
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.
	gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if poleffx==. | age==. | gndr==. | academic==. | zedupar_isled==. | books==. | migration==. | parpol==. | fripol==. | teapol==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// Baseline Multilevel model
	xtmixed poleffx i.wave age gndr academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_1
	mltrsq
	
	// REWB model total socialisation:
	xtmixed poleffx i.wav age gndr academic zedupar_isled books migration intpol discuss_mean_mean disc_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_2
	mltrsq
		
	// REWB model seperate socialisations:
	xtmixed poleffx i.wave age gndr academic zedupar_isled books migration intpol oudpol_mean op_mean_w vripol_mean vp_mean_w lerpol_mean lp_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_3
	mltrsq
	
	estout EPE_3_1 EPE_3_2 EPE_3_3 using "Part 3 External Political Efficacy new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	
	}
	
	
	
	
	*** ROBUSTNESS CHECKS ****
	
	* for the different indicators seperatly
	
	{
		foreach x in effin1 effin2 effin3 effin4 effex1 effex2 {
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data/Werkdataset final.dta", clear
keep if `x'1!=.

	reshape long `x' parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)
	
	
	regress `x' age gndr academic zedupar_isled books migration intpol if wave==1
	est store `x'_1_1
	
	
	* Part 2: Development of of these inequalities over time, using Growth Curve Modelling: 
	
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if `x'1!=.

	reshape long `x' parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if `x'==. | age==. | gndr==. | academic==. | zedupar_isled==. | books==. | migration==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// The growth curve model: 
	xtmixed `x' wave age gndr academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_2_1
	mltrsq 
	// The growth curve model with interaction on gender
	xtmixed `x' c.wave##gndr age academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_2_2
	mltrsq
	
	// The growth curve model with interaction on track
	xtmixed `x' c.wave##academic gndr age zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_2_3
	mltrsq
	
	// The growth curve model with interaction on PEA
	xtmixed `x' c.wave##c.zedupar_isled academic gndr age books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_2_4
	mltrsq
	
	// The growth curve model with interaction on cultural capital
	xtmixed `x' c.wave##c.books zedupar_isled academic gndr age migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_2_5
	mltrsq
	
	// The growth curve model with interaction on migration
	xtmixed `x' c.wave##c.migration books zedupar_isled academic gndr age intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_2_6
	mltrsq
	

	* Part 3: Random Effect Within-Between model to disentangle the effect op political socialisation.
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if `x'1!=.
	gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long `x' parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if `x'==. | age==. | gndr==. | academic==. | zedupar_isled==. | books==. | migration==. | parpol==. | fripol==. | teapol==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// Baseline Multilevel model
	xtmixed `x' i.wave age gndr academic zedupar_isled books migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_3_1
	mltrsq
	
	// REWB model total socialisation:
	xtmixed `x' i.wave age gndr academic zedupar_isled books migration intpol discuss_mean_mean disc_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_3_2
	mltrsq
		
	// REWB model seperate socialisations:
	xtmixed `x' i.wave age gndr academic zedupar_isled books migration intpol oudpol_mean op_mean_w vripol_mean vp_mean_w lerpol_mean lp_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store `x'_3_3
	mltrsq
	
	}

	estout effin1_1_1 effin2_1_1 effin3_1_1 effin4_1_1 using "Part 1 Internal Political Efficacy items new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effex1_1_1 effex2_1_1 using "Part 1 External Political Efficacy items new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace

	estout effin1_2_1 effin2_2_1 effin3_2_1 effin4_2_1 using "Part 2 Internal Political Efficacy items - 1 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effin1_2_2 effin2_2_2 effin3_2_2 effin4_2_2 using "Part 2 Internal Political Efficacy items - 2 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effin1_2_3 effin2_2_3 effin3_2_3 effin4_2_3 using "Part 2 Internal Political Efficacy items - 3 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effin1_2_4 effin2_2_4 effin3_2_4 effin4_2_4 using "Part 2 Internal Political Efficacy items - 4 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effin1_2_5 effin2_2_5 effin3_2_5 effin4_2_5 using "Part 2 Internal Political Efficacy items - 5 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effin1_2_6 effin2_2_6 effin3_2_6 effin4_2_6 using "Part 2 Internal Political Efficacy items - 6 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	
	estout effex1_2_1 effex2_2_1 using "Part 2 External Political Efficacy items - 1 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effex1_2_2 effex2_2_2 using "Part 2 External Political Efficacy items - 2 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effex1_2_3 effex2_2_3 using "Part 2 External Political Efficacy items - 3.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effex1_2_4 effex2_2_4 using "Part 2 External Political Efficacy items - 4 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effex1_2_5 effex2_2_5 using "Part 2 External Political Efficacy items - 5 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effex1_2_6 effex2_2_6 using "Part 2 External Political Efficacy items - 6 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	
	estout effin1_3_1 effin2_3_1 effin3_3_1 effin4_3_1 using "Part 3 Internal Political Efficacy items - 1 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effin1_3_2 effin2_3_2 effin3_3_2 effin4_3_2 using "Part 3 Internal Political Efficacy items - 2 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effin1_3_3 effin2_3_3 effin3_3_3 effin4_3_3 using "Part 3 Internal Political Efficacy items - 3 new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	estout effex1_3_1 effex2_3_1 effex1_3_2 effex2_3_2 effex1_3_3 effex2_3_3 using "Part 3 External Political Efficacy items new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
}

*** without cultural capital
	* Part 1: Inequalities in Year 1: 
	{
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffin1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)
	
	// Baseline multilevel model:
	regress poleffin age gndr academic zedupar_isled migration intpol if wave==1 
	est store IPE_1_1
	
estout IPE_1_1 using "Part 1 Internal Political Efficacy without cult new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace

	
	* Part 2: Development of of these inequalities over time, using Growth Curve Modelling: 

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffin1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)	
	drop if poleffin==. | age==. | gndr==. | academic==. | zedupar_isled==.  | migration==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// The growth curve model: 
	xtmixed poleffin wave age gndr academic zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_1
	mltrsq 
	// The growth curve model with interaction on gender: 
	xtmixed poleffin c.wave##gndr age academic zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_2
	mltrsq
	
	// The growth curve model with interaction on track: 
	xtmixed poleffin c.wave##academic gndr age zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_3
	mltrsq
	
	// The growth curve model with interaction on PEA: 
	xtmixed poleffin c.wave##c.zedupar_isled academic gndr age migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_4
	mltrsq
	
	estout IPE_2_1 IPE_2_2 IPE_2_3 IPE_2_4 using "Part 2 Internal Political Efficacy without cult new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace



	* Part 3: Random Effect Within-Between model to disentangle the effect op political socialisation.

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffin1!=.
	gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if poleffin==. | age==. | gndr==. | academic==. | zedupar_isled==. | migration==. | parpol==. | fripol==. | teapol==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// Baseline Multilevel model
	xtmixed poleffin i.wave age gndr academic zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_1
	mltrsq
	
	// REWB model total socialisation:
	xtmixed poleffin i.wave age gndr academic zedupar_isled migration intpol discuss_mean_mean disc_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_2
	mltrsq
		
	// REWB model seperate socialisations:
	xtmixed poleffin i.wave age gndr academic zedupar_isled migration intpol oudpol_mean op_mean_w vripol_mean vp_mean_w lerpol_mean lp_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_3
	mltrsq
	
	estout IPE_3_1 IPE_3_2 IPE_3_3 using "Part 3 Internal Political Efficacy without cult new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	

	
***************		 ANALYSIS EXTERNAL POLITICAL EFFICACY		***************
	* Part 1: Inequalities in Year 1: 

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)
	
	// Baseline multilevel model:
	regress poleffx age gndr academic zedupar_isled migration intpol if wave==1 
	est store EPE_1_1
	
estout EPE_1_1 using "Part 1 External Political Efficacy without cult new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace

	
	* Part 2: Development of of these inequalities over time, using Growth Curve Modelling: 

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)	
	drop if poleffx==. | age==. | gndr==. | academic==. | zedupar_isled==.  | migration==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// The growth curve model: 
	xtmixed poleffx time age gndr academic zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_1
	mltrsq 
	// The growth curve model with interaction on gender: 
	xtmixed poleffx c.wave##gndr age academic zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_2
	mltrsq
	
	// The growth curve model with interaction on track: 
	xtmixed poleffx c.wave##academic gndr age zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_3
	mltrsq
	
	// The growth curve model with interaction on PEA:
	xtmixed poleffx c.wave##c.zedupar_isled academic gndr age migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_4
	mltrsq
	
	estout EPE_2_1 EPE_2_2 EPE_2_3 EPE_2_4 using "Part 2 External Political Efficacy without cult new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace



	* Part 3: Random Effect Within-Between model to disentangle the effect op political socialisation.

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.
	gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)	
	drop if poleffx==. | age==. | gndr==. | academic==. | zedupar_isled==. | migration==. | parpol==. | fripol==. | teapol==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// Baseline Multilevel model
	xtmixed poleffx i.wave age gndr academic zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_1
	mltrsq
	
	// REWB model total socialisation:
	xtmixed poleffx i.wave age gndr academic zedupar_isled migration intpol discuss_mean_mean disc_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_2
	mltrsq
		
	// REWB model seperate socialisations:
	xtmixed poleffx i.wave age gndr academic zedupar_isled migration intpol oudpol_mean op_mean_w vripol_mean vp_mean_w lerpol_mean lp_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_3
	mltrsq
	
	estout EPE_3_1 EPE_3_2 EPE_3_3 using "Part 3 External Political Efficacy without cult new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	
	}

	*** without educational attainment
	* Part 1: Inequalities in Year 1: 
	{
	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffin1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)
	
	// Baseline multilevel model:
	regress poleffin age gndr books zedupar_isled migration intpol if wave==1 
	est store IPE_1_1
	
estout IPE_1_1 using "Part 1 Internal Political Efficacy without track new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace

	
	* Part 2: Development of of these inequalities over time, using Growth Curve Modelling: 

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffin1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)	
	drop if poleffin==. | age==. | gndr==. | books==. | zedupar_isled==.  | migration==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// The growth curve model: 
	xtmixed poleffin wave age gndr books zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_1
	mltrsq 
	// The growth curve model with interaction on gender: 
	xtmixed poleffin c.wave##gndr age books zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_2
	mltrsq
	
	// The growth curve model with interaction on cultural capital:
	xtmixed poleffin c.wave##books gndr age zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_3
	mltrsq
	
	// The growth curve model with interaction on PEA: 
	xtmixed poleffin c.wave##c.zedupar_isled books gndr age migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_2_4
	mltrsq
	
	estout IPE_2_1 IPE_2_2 IPE_2_3 IPE_2_4 using "Part 2 Internal Political Efficacy without track new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace



	* Part 3: Random Effect Within-Between model to disentangle the effect op political socialisation.

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffin1!=.
	gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol, i(idstudent) j(wave)	
	drop if poleffin==. | age==. | gndr==. | books==. | zedupar_isled==. | migration==. | parpol==. | fripol==. | teapol==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// Baseline Multilevel model
	xtmixed poleffin i.wave age gndr books zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_1
	mltrsq
	
	// REWB model total socialisation:
	xtmixed poleffin i.wave age gndr books zedupar_isled migration intpol discuss_mean_mean disc_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_2
	mltrsq
		
	// REWB model seperate socialisations:
	xtmixed poleffin i.wave age gndr books zedupar_isled migration intpol oudpol_mean op_mean_w vripol_mean vp_mean_w lerpol_mean lp_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store IPE_3_3
	mltrsq
	
	estout IPE_3_1 IPE_3_2 IPE_3_3 using "Part 3 Internal Political Efficacy without track new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	

	
***************		 ANALYSIS EXTERNAL POLITICAL EFFICACY		***************
	* Part 1: Inequalities in Year 1: 

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)
	
	// Baseline multilevel model: 
	regress poleffx age gndr books zedupar_isled migration intpol if wave==1 
	est store EPE_1_1
	
estout EPE_1_1 using "Part 1 External Political Efficacy without track new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace

	
	* Part 2: Development of of these inequalities over time, using Growth Curve Modelling: 

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.

	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)	
	drop if poleffx==. | age==. | gndr==. | books==. | zedupar_isled==.  | migration==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// The growth curve model: 
	xtmixed poleffx wave age gndr books zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_1
	mltrsq 
	// The growth curve model with interaction on gender: 
	xtmixed poleffx c.wave##gndr age books zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_2
	mltrsq
	
	// The growth curve model with interaction on cultural capital: 
	xtmixed poleffx c.wave##books gndr age zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_3
	mltrsq
	
	// The growth curve model with interaction on PEA: 
	xtmixed poleffx c.wave##c.zedupar_isled books gndr age migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_2_4
	mltrsq
	
	estout EPE_2_1 EPE_2_2 EPE_2_3 EPE_2_4 using "Part 2 External Political Efficacy without track new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace



	* Part 3: Random Effect Within-Between model to disentangle the effect op political socialisation.

	use "C:\Users\4023609\Dropbox\PostDoc ADKS UvA\2023 - Inequalities in the development of political efficacy\Analyses\Data\Werkdataset final.dta", replace
keep if poleffx1!=.
	gen parpol_first=parpol1
	gen fripol_first=fripol1
	gen teapol_first=teapol1
	reshape long poleffin poleffx parpol op_mean_w fripol vp_mean_w teapol lp_mean_w discuss_mean_ disc_mean_w oud_disc_prop_ vri_disc_prop_ ler_disc_prop_ disc_oud_prop_w disc_vri_prop_w disc_ler_prop_w idclass intpol , i(idstudent) j(wave)	
	drop if poleffx==. | age==. | gndr==. | books==. | zedupar_isled==. | migration==. | parpol==. | fripol==. | teapol==. | intpol==.
	bysort idstudent:	gen help=_N
	drop if help<2	
	drop help
	
	// Baseline Multilevel model
	xtmixed poleffx i.wave age gndr books zedupar_isled migration intpol || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_1
	mltrsq
	
	// REWB model total socialisation:
	xtmixed poleffx i.wave age gndr books zedupar_isled migration intpol discuss_mean_mean disc_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_2
	mltrsq
		
	// REWB model seperate socialisations:
	xtmixed poleffx i.wave age gndr books zedupar_isled migration intpol oudpol_mean op_mean_w vripol_mean vp_mean_w lerpol_mean lp_mean_w || idstudent: , cov(unstructured) mle 
	estat icc 
	est store EPE_3_3
	mltrsq
	
	estout EPE_3_1 EPE_3_2 EPE_3_3 using "Part 3 External Political Efficacy without track new.txt", cells("b(star fmt(3)) se(fmt(3)) p(fmt(3))")  stats(r2 N) replace
	
	}
